<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('新增盘点')"/>
<meta charset="UTF-8"/>
<title>Title</title>
<!-- load css -->

<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" media="all"/>
<style>

    .layui-form-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>

<body>
<div class="layui-fluid larry-wrapper">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="">
                    &nbsp;
                    &nbsp;
                    <div>
                        <span>全仓盘点</span>
                        <hr>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">盘点编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="pdbh" id="pdbh" readonly placeholder="盘点编号"
                                       data-required="data-required"
                                       autocomplete="off" class="layui-input " style="background:#eef1f6"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">类型</label>
                            <div class="layui-input-inline">
                                <select name="lx" lay-verify="required" data-required="data-required">
                                    <option value="">请选择</option>
                                    <option value="0">普通盘点</option>
                                    <option value="1">差异盘点</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">申请时间</label>
                            <div class="layui-input-inline">
                                <input type="text" id="sqsjs" placeholder="申请时间" lay-verify="required"
                                       data-required="data-required"
                                       autocomplete="off" class="layui-input "/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">盘点方式</label>
                            <div class="layui-input-inline">
                                <select name="pdfs" id="pdfs" lay-verify="required" data-required="data-required"
                                        lay-filter="pdfs" lay-search>
                                    <!--   <select id="pdfs"  lay-filter="pdfs" >-->
                                    <option value="">请选择</option>
                                    <option value="0">全仓盘点</option>
                                    <option value="1">动碰盘点</option>
                                    <option value="2">随机盘点</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">动态盘点</label>
                            <div class="layui-input-inline">
                                <select name="dtpd" lay-verify="required" data-required="data-required">
                                    <option value="">请选择</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">空库位</label>
                            <div class="layui-input-inline">
                                <select name="kkw" lay-verify="required" data-required="data-required">
                                    <option value="">请选择</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" title="包含过渡库位">包含过渡库位</label>
                            <div class="layui-input-inline">
                                <select name="bhgdkw" lay-verify="required" data-required="data-required">
                                    <option value="">请选择</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">盲盘</label>
                            <div class="layui-input-inline">
                                <select name="mp" lay-verify="required" data-required="data-required">
                                    <option value="">请选择</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                    </div>


                    <div style="display: none" id="suijiDiv">
                        <div>
                            <span>随机盘点</span>
                            <hr>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">库存数</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="kcs" name="kcs" placeholder="库存数"
                                           autocomplete="off" class="layui-input "/>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">精确条件</label>
                                <div class="layui-input-inline">
                                    <select id="sjjqtj" lay-filter="sjjqtj" lay-search>
                                        <option value="">请选择</option>
                                        <option value="0">产品</option>
                                        <option value="1">库位</option>
                                        <option value="2">库区</option>
                                        <option value="3">种类</option>
                                    </select>
                                </div>
                            </div>
                            <div id="sjproductDiv" style="display: none">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品</label>
                                        <div class="layui-input-inline">
                                            <select lay-ignore="lay-ignore" class="sjcpid" id="sjcpid" select2
                                                    style="width: 193px" onchange="cpidValue('suiji')"></select>
                                            <!--<input type="text" id="sjcpid"  name="cpid" placeholder="产品"
                                                   autocomplete="off" class="layui-input "/>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="sjkuweiDiv" style="display: none">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">库位名称</label>
                                        <div class="layui-input-inline">
                                            <select lay-ignore="lay-ignore" class="sjkwid" id="sjkwid" select2
                                                    style="width: 193px" onchange="kwidValue('suiji')"></select>

                                            <!-- <input type="text" id="sjkwid" name="cpid" placeholder="盘点编号"
                                                    autocomplete="off" class="layui-input "
                                                  />-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="sjkuquDiv" style="display: none">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">库区名称</label>
                                        <div class="layui-input-inline">
                                            <select lay-ignore="lay-ignore" class="sjkqid" id="sjkqid"
                                                    style="width: 193px" onchange="kqidValue('suiji')"></select>

                                            <!--<input type="text" id="sjkqid" placeholder="盘点编号"
                                                   autocomplete="off" class="layui-input "
                                                   />-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="sjzhongleiDiv" style="display: none">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">货品种类</label>
                                        <div class="layui-input-inline">
                                            <select lay-ignore="lay-ignore" class="sjzlid" id="sjzlid"
                                                    style="width: 193px" onchange="zlidValue('suiji')"></select>
                                            <!--<input type="text" id="sjzlid" placeholder="货品种类"
                                                   autocomplete="off" class="layui-input "
                                                   />-->
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div style="display: none" id="dongpengDiv">
                        <div>
                            <span>动碰盘点</span>
                            <hr>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">开始时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="dpkssjs" placeholder="开始时间"
                                           autocomplete="off" class="layui-input "/>
                                    <input type="hidden" id="dpkssj" name="dpkssj">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">结束时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="dpjssjs" placeholder="结束时间"
                                           autocomplete="off" class="layui-input "/>
                                    <input type="hidden" id="dpjssj" name="dpjssj">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">精确条件</label>
                                <div class="layui-input-inline">
                                    <select id="dpjqtj" lay-filter="jqtj" lay-search>
                                        <option value="">请选择</option>
                                        <option value="0">产品</option>
                                        <option value="1">库位</option>
                                        <option value="2">库区</option>
                                        <option value="3">种类</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline" id="dpproductDiv" style="display: none">
                                <label class="layui-form-label">产品</label>
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="dpcpid" id="dpcpid" select2
                                            lay-filter="dpcpid" lay-search style="width: 193px"
                                            onchange="cpidValue('dp')"></select>
                                    <!--<input type="text" id="dpcpid" placeholder="产品" lay-verify="required"
                                           autocomplete="off" class="layui-input "  />-->
                                </div>
                            </div>

                            <div class="layui-inline" id="dpkuweiDiv" style="display: none">
                                <label class="layui-form-label">库位名称</label>
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="dpkwid" id="dpkwid" name="kwid" select2
                                            lay-filter="dpkwid" style="width: 193px"
                                            onchange="kwidValue('dp')"></select>
                                    <!-- <input type="text" id="dpkwid" placeholder="库位名称" lay-verify="required"
                                            autocomplete="off" class="layui-input " />-->
                                </div>
                            </div>


                            <div class="layui-inline" id="dpkuquDiv" style="display: none">
                                <label class="layui-form-label">库区名称</label>
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="dpkqid" id="dpkqid" name="kqid" select2
                                            lay-filter="dpkqid" style="width: 193px"
                                            onchange="kqidValue('dp')"></select>
                                    <!-- <input type="text" id="dpkqid" placeholder="盘点编号" lay-verify="required"
                                            autocomplete="off" class="layui-input "  />-->
                                </div>
                            </div>

                            <div class="layui-inline" id="dpzhongleiDiv" style="display: none">
                                <label class="layui-form-label">货品种类</label>
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="dpzlid" id="dpzlid" name="zlid" select2
                                            lay-filter="dpzlid" style="width: 193px"
                                            onchange="zlidValue('dp')"></select>
                                    <!--  <input type="text" id="dpzlid" placeholder="货品种类" lay-verify="required"
                                             autocomplete="off" class="layui-input "  />-->
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="layui-form-item" style="float: right;">
                        <div class="layui-input-block">
                            <button class="layui-btn" jq-filter="submit" lay-submit="" lay-filter="addCustomer">保存
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                    <input type="hidden" name="sqsj" id="sqsj">
                    <!--全仓盘点-->
                    <input type="hidden" name="qcpd" id="qcpd">
                    <!--动碰盘点-->
                    <input type="hidden" name="dppdzt" id="dppdzt">
                    <!-- 随机盘点-->
                    <input type="hidden" name="sjpd" id="sjpd">
                    <!-- 精确条件-->
                    <input type="hidden" name="jqtj" id="jqtj">
                    <!-- 产品-->
                    <input type="hidden" name="cpid" id="cpid">
                    <!--库位-->
                    <input type="hidden" name="kwid" id="kwid">
                    <!-- 库区-->
                    <input type="hidden" name="kqid" id="kqid">
                    <!--种类-->
                    <input type="hidden" name="zlid" id="zlid">
                </form>
            </section>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/plugin/layui/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/version.js}"></script>
<script th:src="@{/plugin/layui/js/common.js}"></script>
<div th:include="public/public_js::public_js"></div>
<script>
    $(function () {

        /* //加载省份
         $("#sheng").html("");
         var str = "<option>==请选择===</option>";
         $.ajax({
         type: "GET",
         url: "/zxbzwms/wmscityinfo/selectProvice/1",

         dataType: "JSON",
         async: false,
         success: function (data) {
         console.info(data);
         //从服务器获取数据进行绑定
         $.each(data, function (i, item) {
         console.info("item.cityname"+item.cityname);
         console.info(item.citycode);
         str += "<option value=" + item.cityname + " code="+item.citycode+">" + item.cityname + "</option>";
         })
         //将数据添加到省份这个下拉框里面
         $("#sheng").append(str);

         },
         error: function () { alert("Error"); }
         });*/
    });

</script>
<script>


    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'form'], function () {
        var form = layui.form,
            zzpUtils = layui.zzpUtils,
            laydate = layui.laydate;
        $ = layui.jquery;
        //获取盘点编号
        $.ajax({
            type: "GET",
            url: "/zxsdwms/wmsinventoryplan/getPdBh",
            dataType: "JSON",
            async: false,
            success: function (data) {
                $("#pdbh").val(data);
            },
            error: function () {
                alert("Error");
            }
        });

        /* 申请时间*/
        laydate.render({
            elem: '#sqsjs',
            type: 'datetime',
            done: function (value, date, endDate) {
                if (value != null && value != '') {
                    $("#sqsj").val(Date.parse(value));
                } else {
                    $("#sqsj").val("");
                }

            }
        });
        /* 动碰开始时间*/
        laydate.render({
            elem: '#dpkssjs',
            type: 'datetime',
            done: function (value, date, endDate) {
                if (value != null && value != '') {
                    $("#dpkssj").val(Date.parse(value));
                } else {
                    $("#dpkssj").val("");
                }

            }
        });
        /*动碰结束时间*/
        laydate.render({
            elem: '#dpjssjs',
            type: 'datetime',
            done: function (value, date, endDate) {
                if (value != null && value != '') {
                    $("#dpjssj").val(Date.parse(value));
                } else {
                    $("#dpjssj").val("");
                }
            }
        });

        //盘点方式触发条件
        form.on('select(pdfs)', function (data) {
            if ($("#pdfs").val() == 2) {//随机盘点
                $("#suijiDiv").show();
                $("#dongpengDiv").hide();
                $("#qcpd").val("0");
                $("#dppdzt").val("0");
                $("#sjpd").val("1");
                $("#cpid").val("");
                $("#kwid").val("");
                $("#kqid").val("");
                $("#zlid").val("");
            } else if ($("#pdfs").val() == 1) {//动碰盘点
                $("#suijiDiv").hide();
                $("#dongpengDiv").show();
                $("#qcpd").val("0");
                $("#dppdzt").val("1");
                $("#sjpd").val("0");

                $("#cpid").val("");
                $("#kwid").val("");
                $("#kqid").val("");
                $("#zlid").val("");
            } else {//全仓盘点
                $("#qcpd").val("1");
                $("#dppdzt").val("0");
                $("#sjpd").val("0");
                $("#cpid").val("");
                $("#kwid").val("");
                $("#kqid").val("");
                $("#zlid").val("");
            }
        });

        window.cpidValue = function (type) {
            if (type == 'dp') {
                $("#cpid").val($("#dpcpid").val());
            } else if (type == 'suiji') {
                $("#cpid").val($("#sjcpid").val());
            }

        };
        window.kwidValue = function (type) {
            if (type == 'dp') {
                $("#kwid").val($("#dpkwid").val());
            } else if (type == 'suiji') {
                $("#kwid").val($("#sjkwid").val());
            }
        };
        window.kqidValue = function (type) {
            if (type == 'dp') {
                $("#kqid").val($("#dpkqid").val());
            } else if (type == 'suiji') {
                $("#kqid").val($("#sjkqid").val());
            }

        };
        window.zlidValue = function (type) {
            if (type == 'dp') {
                $("#zlid").val($("#dpzlid").val());
            } else if (type == 'suiji') {
                $("#zlid").val($("#sjzlid").val());
            }

        };
        //  动态盘点精确条件触发事件alert
        form.on('select(jqtj)', function (data) {
            if ($("#dpjqtj").val() == 0) {
                $("#dpproductDiv").show();
                $("#dpkuweiDiv").hide();
                $("#dpkuquDiv").hide();
                $("#dpzhongleiDiv").hide();
                $('.dpcpid').select2({
                    ajax: {
                        url: '/zxsdwms/wmsgoods/getGoodsBySshzid',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                bh: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    console.info(data.rows[i].bh);
                                    arr.push({id: data.rows[i].id, text: data.rows[i].bh});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            } else if ($("#dpjqtj").val() == 1) {
                $("#dpproductDiv").hide();
                $("#dpkuweiDiv").show();
                $("#dpkuquDiv").hide();
                $("#dpzhongleiDiv").hide();
                $('.dpkwid').select2({
                    ajax: {
                        url: '/zxsdwms/wmslibraryposition/getLibrarysBymc',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    console.info(data.rows[i].bh);
                                    arr.push({id: data.rows[i].id, text: data.rows[i].mc});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            } else if ($("#dpjqtj").val() == 2) {
                $("#dpproductDiv").hide();
                $("#dpkuweiDiv").hide();
                $("#dpkuquDiv").show();
                $("#dpzhongleiDiv").hide();
                $('.dpkqid').select2({
                    ajax: {
                        url: '/zxsdwms/wmslibraryposition/addSearchArea',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.length; i++) {
                                    console.info(data.bh);
                                    arr.push({id: data[i].dictionaryid, text: data[i].value});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            } else if ($("#dpjqtj").val() == 3) {
                $("#dpproductDiv").hide();
                $("#dpkuweiDiv").hide();
                $("#dpkuquDiv").hide();
                $("#dpzhongleiDiv").show();
                $('.dpzlid').select2({
                    ajax: {
                        url: '/zxsdwms/wmsgoodstype/getWmsGoodsTypeByHzId',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.length; i++) {
                                    arr.push({id: data[i].id, text: data[i].mc});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            }
        })


        form.on('select(sjjqtj)', function (data) {
            if ($("#sjjqtj").val() == 0) {//产品
                $("#sjproductDiv").show();
                $("#sjkuweiDiv").hide();
                $("#sjkuquDiv").hide();
                $("#sjzhongleiDiv").hide();
                $('.sjcpid').select2({
                    ajax: {
                        url: '/zxsdwms/wmsgoods/getGoodsBySshzid',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                bh: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    console.info(data.rows[i].bh);
                                    arr.push({id: data.rows[i].id, text: data.rows[i].bh});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });

            } else if ($("#sjjqtj").val() == 1) {//库位
                $("#sjproductDiv").hide();
                $("#sjkuweiDiv").show();
                $("#sjkuquDiv").hide();
                $("#sjzhongleiDiv").hide();
                $('.sjkwid').select2({
                    ajax: {
                        url: '/zxsdwms/wmslibraryposition/getLibrarysBymc',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    console.info(data.rows[i].bh);
                                    arr.push({id: data.rows[i].id, text: data.rows[i].mc});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            } else if ($("#sjjqtj").val() == 2) {//库区
                $("#sjproductDiv").hide();
                $("#sjkuweiDiv").hide();
                $("#sjkuquDiv").show();
                $("#sjzhongleiDiv").hide();
                $('.sjkqid').select2({
                    ajax: {
                        url: '/zxsdwms/wmslibraryposition/addSearchArea',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.length; i++) {
                                    console.info(data.bh);
                                    arr.push({id: data[i].dictionaryid, text: data[i].value});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            } else if ($("#sjjqtj").val() == 3) {//种类
                $("#sjproductDiv").hide();
                $("#sjkuweiDiv").hide();
                $("#sjkuquDiv").hide();
                $("#sjzhongleiDiv").show();
                $('.sjzlid').select2({
                    ajax: {
                        url: '/zxsdwms/wmsgoodstype/getWmsGoodsTypeByHzId',
                        dataType: 'json',
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr = new Array();
                            if (data) {
                                for (var i = 0; i < data.length; i++) {
                                    arr.push({id: data[i].id, text: data[i].mc});
                                }
                            }
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入查询字段',
                    allowClear: true
                });
            }
        })


        zzpUtils.select2({
            elem: "#selectId",  //dom
            url: "/wmsCustomerFiles/baseSelectLine" //路径
        });

        form.on("submit(addCustomer)", function (data) {
            var flag = true;
            if ($("#pdfs").val() == 1) {//动碰盘点
                if ($("#dpkssj").val() == null || $("#dpkssj").val() == "" || $("#dpjssj").val() == null || $("#dpjssj").val() == "") {
                    flag = false;
                }
            }
            if ($("#pdfs").val() == 2) {//随机盘点
                if ($("#kcs").val() == null || $("#kcs").val() == "" ) {
                    flag = false;
                }
            }
            if (flag == true) {
                zzpUtils.confirm("是否确定添加", function (index) {
                    zzpUtils.action({
                        url: "/wmsinventoryplan/add",
                        data: JSON.stringify(data.field),
                        success: function (data) {
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                console.info(data);
                                top.layer.msg(data.title + "," + data.message);
                                //刷新父页面
                            }, 500);
                        }, error: function (xhr, textStatus) {
                            console.log(textStatus);
                            console.log(xhr)
                        }
                    })
                })
            }else {
                top.layer.msg("请完整表单信息");
            }
            return false;

        });


        form.on('select(sheng)', function (data) {
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            var sheng = $("#sheng").find("option:selected").attr("code");
            //判断省份这个下拉框选中的值是否为空
            if (sheng == "") {
                return;
            }
            $("#shi").html("");
            var str = "<option>==请选择===</option>";
            $.ajax({
                type: "GET",
                url: "/zxbzwms/wmscityinfo/selectProvice/" + sheng,
                dataType: "JSON",
                async: false,
                success: function (data) {
                    //从服务器获取数据进行绑定
                    $.each(data, function (i, item) {
                        str += "<option value=" + item.cityname + ">" + item.cityname + "</option>";
                    })
                    console.info(str);
                    //将数据添加到省份这个下拉框里面
                    $("#shi").append(str);
                    console.info($("#shi").html());
                    form.render('select');
                },
                error: function () {
                    alert("Error");
                }
            });

        });
    });
</script>
</html>